package com.mo.controller;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import com.mo.entity.Student;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author moon.pan
 * @program mo-all
 * @apiNote
 * @since 2022/3/28
 */
@RequestMapping("/student")
@RestController
public class StudentController {

    @GetMapping
    public Map<String, Object> student() {
        Student student = new Student();
        student.setId(IdUtil.objectId());
        student.setName("墨渐生微");
        student.setPrice(22.19666666666);

        HashMap<String, Object> score1 = new HashMap<>();
        score1.put("数学", 63.6984);
        score1.put("语文", 78.6984);
        score1.put("英文", 63.6984);


        HashMap<String, Object> score2 = new HashMap<>();
        score2.put("数学", 63.6984);
        score2.put("语文", 78.6984);
        score2.put("英文", 63.6984);
        score2.put("big", new BigDecimal("6545.54567987456456"));

        student.setScore(CollectionUtil.newArrayList(score1, score2));


        ArrayList<Object> result = new ArrayList<>();
        result.add(new BigDecimal("66456.546546"));
        result.add(new BigDecimal("66456.1231454"));
        result.add(new BigDecimal("66456.546512313446"));
        result.add(new BigDecimal("66456.4564"));
        result.add(8789.5467987);

        student.setResult(result);


        Map<String, Object> map = new HashMap<>();
        map.put("student", student);

        return map;
    }
}
